package com.redis.transaction.entity;

import com.redis.transaction.enums.GameTransactionCommitResult;
import com.redis.transaction.exception.GameTransactionException;
import com.redis.transaction.lock.GameTransactionLockInterface;

/**
 * 游戏事务实体接口
 */
public interface GameTransactionEntityInterface {

    /**
     * 执行
     */
    void commit() throws GameTransactionException;

    /**
     * 回滚
     */
    void rollback() throws GameTransactionException;

    /**
     * 尝试性提交
     */
    GameTransactionCommitResult trycommit() throws GameTransactionException;


    /**
     * 是否可以创建锁
     *
     * @return
     */
    boolean createGameTransactionLock(long seconds) throws GameTransactionException;

    /**
     * 释放锁
     *
     * @return
     */
    void releaseGameTransactionLock();

    /**
     * 强制释放锁
     *
     * @return
     */
    void forceReleaseGameTransactionLock();


    String getInfo();

    /**
     * 是否需要执行
     *
     * @return
     */
    boolean needCommit();

    /**
     * 获取锁内容
     *
     * @return
     */
    GameTransactionLockInterface getGameTransactionLockInterface();
}

